<?php
$line= $registers[0]['User'];
$this->CSV->addRow(array_keys($line));
foreach ($registers as $key => $row)
{
    $row['User']['No.'] = $key+1;
    $this->CSV->addRow($row['User']);
}

$date = new DateTime();
$date->add(new DateInterval('PT14H'));
$exportDate = $date->format('Ymd');
            
$filename='register_' . $exportDate;
echo  $this->CSV->render($filename);
